package com.youngjun.user.controller.admin;

import com.youngjun.common.mybatis.web.BaseController;
import com.youngjun.common.mybatis.web.Response;
import com.youngjun.user.api.admin.IFunctionRestApi;
import com.youngjun.user.pojo.dto.FunctionDTO;
import com.youngjun.user.pojo.vo.FunctionVO;
import com.youngjun.user.service.FunctionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/function")
public class FunctionController implements IFunctionRestApi,BaseController {

    @Autowired
    FunctionService functionService;

    @Override
    public Response<List<FunctionVO>> queryAllowAccessFunctionList(Long roleId) {
        List<FunctionVO> data = functionService.queryAllowAccessFunctionList(roleId);
        return new Response<>(data);
    }

    @Override
    public Response<List<FunctionVO>> queryAllowAssignFunctionList(Long roleId) {
        List<FunctionVO> data = functionService.queryAllowAssignFunctionList(roleId);
        return new Response<>(data);
    }

    @Override
    public Response<List<FunctionVO>> queryList() {
        List<FunctionVO> data = functionService.queryList();
        return new Response<>(data);
    }

    @Override
    public Response<FunctionVO> create(FunctionDTO dto) {
        FunctionVO data = functionService.create(dto);
        return new Response<>(data);
    }

    @Override
    public Response<FunctionVO> modify(FunctionDTO dto) {
        FunctionVO data = functionService.modify(dto);
        return new Response<>(data);
    }

    @Override
    public Response<Void> delete(Long id) {
        functionService.delete(id);
        return new Response<>();
    }

}